package com.sinven.controller;

import com.sinven.pojo.Article;
import com.sinven.pojo.Category;
import com.sinven.service.ArticleService;
import com.sinven.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller("frontArticle")
@RequestMapping("article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @Autowired
    private CategoryService categoryService;
    @RequestMapping("{id}")
    public String findArticle(@PathVariable("id")Long id){
        Article article = articleService.queryArticle(id);
        Category category = categoryService.queryCategoryById(article.getCid());
        return "redirect:/culture/"+category.getCode()+"/"+id;
    }
}
